{extend name="admin@public/basic" /}
{block name="style"}{/block}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{block name="cotent"}
<form class="layui-form form-width-99admin">
    <br>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">用户头像</label>
        <div class="layui-input-block" id="upload_image_div">
            <input type="hidden" id="head_img" value="{$member.head_img|default=''}">
            <div class="uploadimage" data-upload-image="one" data-upload-id="head_img" data-upload-div="upload_image_div" style="background-image: url(__STATIC__/image/admin/upload.png);">
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">用户昵称</label>
        <div class="layui-input-block">
            <input type="text" id="nickname" class="layui-input" lay-verify="required" value="{$member.nickname|default=''}" placeholder="请输入管理账号">
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">登录账户</label>
        <div class="layui-input-block">
            <input type="text" id="username" class="layui-input" lay-verify="required" value="{$member.username|default=''}" placeholder="请输入管理账号" {if isset($member.username)}readonly{/if}>
        </div>
    </div>

    {if empty($member)}
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">初始密码</label>
        <div class="layui-input-block">
            <input type="password" id="password" class="layui-input" lay-verify="required" placeholder="请输入初始密码">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password" id="password1" class="layui-input" lay-verify="required" placeholder="请输入确认密码">
        </div>
    </div>
    {/if}

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">手机</label>
        <div class="layui-input-block">
            <input type="text" id="phone" class="layui-input" value="{$member.phone|default=''}" placeholder="请输入手机">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="email" id="email" class="layui-input" value="{$member.email|default=''}" placeholder="请输入邮箱">
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入备注信息" id="remark" class="layui-textarea">{$member.remark|default=''}</textarea>
        </div>
    </div>

    {if !empty($member)}
    <input type="hidden" class="id" id="id" value="{$member.id|default=''}">
    {/if}

    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" id="submitBtn">提交</button>
            <button class="layui-btn layui-btn-sm layui-btn-primary" data-close="closeOpen">取消</button>
        </div>
    </div>
</form>
{/block}

{block name="script"}
<script>

    /**
     * 上传图片处理
     */
    $.form.imageRender('upload_image_div', 'one');

    /**
     * 添加、编辑
     */
    $("#submitBtn").on("click", function () {
        var url = '{if empty($member)}{:url("$thisClass/add")}{else/}{:url("$thisClass/edit")}{/if}';
        var data = {
            id: $("#id").val(),
            head_img: $("#head_img").val(),
            nickname: $("#nickname").val(),
            username: $("#username").val(),
            password: $("#password").val(),
            password1: $("#password1").val(),
            phone: $("#phone").val(),
            qq: $("#qq").val(),
            email: $("#email").val(),
            remark: $("#remark").val(),
        };
        $.request.post(url, data, function (res) {
            $.msg.success(res.msg, function () {
                $.tool.reload('open');
            })
        })
        return false;
    });
</script>
{/block}
